package cn.wolfcode.product._1product;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;

import java.io.UnsupportedEncodingException;

public class ProductTest {

    public static void main(String[] args) throws MQClientException, UnsupportedEncodingException, RemotingException, InterruptedException, MQBrokerException {

        //创建一个生产者对象，并且制定一个生产者组
        DefaultMQProducer producer = new DefaultMQProducer("wolfcode-producer");
        //设置名字服务的地址
        producer.setNamesrvAddr("127.0.0.1:9876");
        //启动生产者
        producer.start();
        //创建一个消息
        Message message = new Message("1_hello","tagA","hello rocketmg".getBytes("utf-8"));
        //发送消息
        producer.send(message);
        //关闭连接
        producer.shutdown();


    }
}
